package com.ita.iosa.DBtest;

import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.List;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import com.ita.iosa.dao.MerchantDao;
import com.ita.iosa.dao.MerchantStatusDao;
import com.ita.iosa.dao.impl.MerchantDaoImpl;
import com.ita.iosa.dao.impl.MerchantStatusDaoImpl;
import com.ita.iosa.po.Merchant;
import com.ita.iosa.po.MerchantStatus;

public class DBOperateTest {
	private  MerchantStatusDao msd = new MerchantStatusDaoImpl();
	private  MerchantDao md = new MerchantDaoImpl();
	
	@Test
	public void addMerchantStatusTest() {
		MerchantStatus ms = new MerchantStatus(4, 0);
		int m = msd.addMerchantStatus(ms);
		Assert.assertTrue(m==1);
	}
	
	@Test
	public void updateMerchantStatusTest() {
		int m = msd.updateMerchantStatus(1, 2);
		Assert.assertTrue(m==1);
	}
	
	@Test
	public void selectAllMerchantStatusTest() {
		HashMap<Integer, Integer> status = new HashMap<Integer, Integer>();
		status = msd.selectAllMerchantStatus();
		Assert.assertTrue(!status.isEmpty());
	}
	
	@Test
	public void seleteMerchantStatusMidTest() {
		int m = msd.seleteMerchantStatusMid(2);
		Assert.assertTrue(m==1);
	}
	
	@Test
	public void selectOneMerchantTest() {
		Merchant merchant = md.selectOneMerchant(1);
		Assert.assertTrue(merchant != null);
	}
	
	@Test
	public void selectWaitMidTest() {
		List<Integer> waitMids = msd.selectWaitMid();
		Assert.assertTrue(!waitMids.isEmpty());
	}
	
	@Test
	public void addMerchantTest() {
		int m = md.addMerchant(new Merchant(4, "diana", "chuancai", "zhuhai", "13631217884", "haha", "haochi", "qd9611@163.com", "2333"));
		Assert.assertTrue(m==1);
	}
}
